//
//  JJHttpClient.h
//  jiajia
//
//  Created by rujia chen on 16/5/1.
//  Copyright © 2016年 sunrisin. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void (^SuccessBlock)(NSURLSessionTask *task, NSDictionary *response);
typedef void (^FailBlock)(NSURLSessionTask *task, NSInteger errcode, NSString *errmsg);
typedef void (^ExceptionBlock)(NSURLSessionTask *task, NSError *error);

@interface JJHttpClient : NSObject

@property (nonatomic, copy, readonly) NSString *hostName;

+ (JJHttpClient*)client;

/**
 *  增加请求头数据
 *
 */
- (void)addValue:(id)value forHTTPHeaderField:(NSString *)field;

/**
 *  取得请求头中的信息
 */
- (NSDictionary*)allHTTPRequestHeader;

- (NSURLSessionTask*)GET:(NSString*)url
                   params:(NSDictionary*)params
             successBlock:(SuccessBlock)successBlock
                failBlock:(FailBlock)failBlock
           exceptionBlock:(ExceptionBlock)exceptionBlock;

- (NSURLSessionTask*)POST:(NSString*)url
                   params:(NSDictionary*)params
             successBlock:(SuccessBlock)successBlock
                failBlock:(FailBlock)failBlock
           exceptionBlock:(ExceptionBlock)exceptionBlock;

- (NSURLSessionTask*)PUT:(NSString*)url
                   params:(NSDictionary*)params
             successBlock:(SuccessBlock)successBlock
                failBlock:(FailBlock)failBlock
           exceptionBlock:(ExceptionBlock)exceptionBlock;

- (NSURLSessionTask*)DELETE:(NSString*)url
                   params:(NSDictionary*)params
             successBlock:(SuccessBlock)successBlock
                failBlock:(FailBlock)failBlock
           exceptionBlock:(ExceptionBlock)exceptionBlock;

@end
